#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

#define DEBUG 0
#define NOISY_TEST 1

int check_discardCard(int handPos, int player, struct gameState *post, int trashFlag){

  // struct gameState pre;
  // memcpy (&pre, post, sizeof(struct gameState));

  int r;

	// r = drawCard (p, post);
  
  // player = 0 or 1
  // trashFlag = 0, 1 or 2
  if(player == 0){
	r = discardCard(handPos, player, post, trashFlag);
  }
  if(player == 1){
	r = discardCard(handPos, player, post, trashFlag);
  }

  assert (r == 0);
  return 0;

  // assert(memcmp(&pre, post, sizeof(struct gameState)) == 0);
}

int main () {

  int i, n, player, trashFlag, handPos;

  int k[10] = {adventurer, council_room, feast, gardens, mine,
	       remodel, smithy, village, baron, great_hall};

  struct gameState G;

  printf ("Testing discardCard.\n");

  SelectStream(2);
  PutSeed(3);

  for (n = 0; n < 1000; n++) {
    for (i = 0; i < sizeof(struct gameState); i++) {
      ((char*)&G)[i] = floor(Random() * 256);
    }

	player = floor(Random() * 2);

    G.deckCount[player] = floor(Random() * MAX_DECK);
    G.discardCount[player] = floor(Random() * MAX_DECK);
    G.handCount[player] = floor(Random() * MAX_HAND);

    handPos = floor(Random() * G.handCount[player]);	
	
	trashFlag = 1;
	
	check_discardCard(handPos, player, &G, trashFlag);
	
  }

  printf ("ALL TESTS OK\n");

  exit(0);

  return 0;
}
